package com.zj.user.service.impl;

import com.zj.user.Repository.UserRepository;
import com.zj.user.domain.User;
import com.zj.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: zj
 * @Date: 2018/11/14 09:50
 * @Description:
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserRepository userRepository;

    @Override
    public User findOneTest(Integer id) {
        return userRepository.findOneById( id );
    }

    @Override
    public User findOneUserByUsername(String username) {
        return userRepository.findOneByUsername( username );
    }

    @Override
    public User findOneUserById(Integer id) {
        return userRepository.findOneById( id );
    }

    @Override
    public User UpDate(User user) {
        return userRepository.save( user );
    }

    @Override
    public List<User> selectAllUser() {
        return userRepository.findAll();
    }

    @Override
    public void deleteUserByUserId(Integer userId) {
        userRepository.deleteById( userId );
    }
}
